package ThreadPoolCheck.RuleIssue;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

/**
 * Created by wangyg6 on 2017/11/7.
 */
public class TestDemo {
	static ExecutorService executes;

	private TestDemo() {
	}

	private static volatile TestDemo instance = new TestDemo();

	public static TestDemo getInstance() {
		return instance;
	}

	static MapCache mapCache = MapCache.getInstance();

	static {
		executes = Executors.newFixedThreadPool(10);
	}

	public static void main(String[] args) throws ExecutionException, InterruptedException {
		List<FutureTask<String>> future=new ArrayList<>();
		for (int i = 1; i <10; i++) {
			FutureTask<String> task= new FutureTask<>(new FirstFloor(i+""));
			future.add(task);
			executes.submit(task);

		}
		for (FutureTask<String> task : future) {
			String s = task.get();
		}
	}
/*
	public static void main(String[] args) throws InterruptedException {
		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				mapCache.getCache().put("prefix", String.valueOf(i));
				Thread.sleep((long) Math.random() * FinalConst.BASIC_SLEEP_TIME);
				System.out.println(mapCache.getCache().get("prefix") + j);
			}
		}
	}*/

}
